<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>实名认证</title>
    <meta content='width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0, shrink-to-fit=no'
          name='viewport'/>
    <link rel="stylesheet" href="assets/css/bootstrap.min.css">
    <link rel="stylesheet"
          href="https://fonts.googleapis.com/css?family=Nunito:200,200i,300,300i,400,400i,600,600i,700,700i,800,800i,900,900i">
    <link rel="stylesheet" href="assets/css/ready.css">
    <link rel="stylesheet" href="assets/css/demo.css">
    <script src="bootstrap/js/jquery.min.js"></script>
    <link rel="stylesheet" href="layer/theme/default/layer.css">
    <script src="layer/layer.js"></script>
    <style type="text/css">
        .main-panel {
            background-color: #FFFFFF !important;
        }

        .content {
            background-color: #FFFFFF !important;
        }

        /*.card-body{*/
        /*    position: relative;*/
        /*}*/
        #cardDemo {
            /*position: absolute;*/
            /*top: 10px;*/
            /*right: 20px;*/
            margin-bottom: 10px;
        }
    </style>
    <script>
        var index = -1;
        var imgName;
        var userid = JSON.parse(sessionStorage.getItem("user")).userid;
        var username = JSON.parse(sessionStorage.getItem("user")).username;
        $("#username").html(username);
        $(function () {
            $("#save").attr('disabled', "true");//添加disabled属性
        })

        //身份证上传提交
        function upload() {
            index = layer.load(1);
            var img = new FormData();
            img.append("img", $("#img").get(0).files[0]);
            $.ajax({
                url: "http://localhost:8007/file/upload/" + userid,
                type: "POST",
                data: img,
                processData: false,
                contentType: false,
                success: function (data) {
                    layer.close(index);
                    layer.msg(data.msg);
                    if (data.code === 1) {
                        //保存图片名称路径
                        imgName = data.data;
                        $("#imgPath").attr("src", "../uploadFile/" + data.data);
                        $('#save').removeAttr("disabled"); //移除disabled属性
                    }
                },
                error: function () {
                    layer.close(index);
                    alert("请选择身份证图片上传");
                }
            });
        }

        //退出登录
        function quiet() {
            sessionStorage.clear()
            window.location.href = "../homePage/index.html";
        }

        //实名认证
        function save() {
            index = layer.load(1);
            $.ajax({
                url: "http://localhost:8007/file/save/" + userid,
                type: "GET",
                success: function (data) {
                    layer.close(index);
                    layer.msg(data.msg);
                    if (data.code === 1) {
                        layer.msg(data.msg);
                    }
                },
                error: function () {
                    layer.close(index);
                    alert("认证失败");
                }
            });
        }


    </script>
</head>
<div class="wrapper">
    <div class="main-header">
        <div class="logo-header">
            <a href="index.html" class="logo">
                <img src="../homePage/img/logo.png" style="height: 40px;width: 100px">个人中心
            </a>
            <button class="navbar-toggler sidenav-toggler ml-auto" type="button" data-toggle="collapse"
                    data-target="collapse"
                    aria-controls="sidebar" aria-expanded="false" aria-label="Toggle navigation">
                <span class="navbar-toggler-icon"></span>
            </button>
            <button class="topbar-toggler more"><i class="la la-ellipsis-v"></i></button>
        </div>
        <nav class="navbar navbar-header navbar-expand-lg">
            <div class="container-fluid">
                <a href="../homePage/index.html" style="color: #000000; font-size: 16px;">返回首页</a>

                <ul class="navbar-nav topbar-nav ml-md-auto align-items-center">


                    <li class="nav-item dropdown">
                        <a class="dropdown-toggle profile-pic" data-toggle="dropdown" href="#" aria-expanded="false">
                            <span id="username"></span>
                        </a>
                        <ul class="dropdown-menu dropdown-user">
                            <li>
                                <div class="user-box">

                                    <div class="u-text">
                                        <a onclick="quiet()" class="btn btn-rounded btn-danger btn-sm">退出登录</a>
                                    </div>
                                </div>
                            </li>

                        </ul>
                        <!-- /.dropdown-user -->
                    </li>
                </ul>
            </div>
        </nav>
    </div>
    <div class="sidebar">
        <div class="scrollbar-inner sidebar-wrapper">
            <div class="user">
                <div class="info">
                    <a class="" data-toggle="collapse" href="#collapseExample" aria-expanded="true">
								<span>
									用户名
									<span class="user-level">身份等级</span>
                                    <!-- <span class="badge badge-count">未实名</span> -->
									<span class="caret"></span>
								</span>
                    </a>
                    <div class="clearfix"></div>

                    <div class="collapse in" id="collapseExample" aria-expanded="true" style="">
                        <ul class="nav">
                            <li>
                                <a href="#profile">
                                    <span class="link-collapse">返回首页</span>
                                </a>
                            </li>
                            <li>
                                <a href="password.html">
                                    <span class="link-collapse">修改密码</span>
                                </a>
                            </li>
                            <li>
                                <a href="#edit">
                                    <span class="link-collapse">实名认证</span>
                                </a>
                            </li>
                            <li>
                                <a href="update.html">
                                    <span class="link-collapse">编辑资料</span>
                                </a>
                            </li>
                        </ul>
                    </div>
                </div>
            </div>
            <ul class="nav">
                <li class="nav-item">
                    <a href="home.html">
                        <i class="la la-fonticons"></i>
                        <p>首页管理</p>
                        <!-- <span class="badge badge-count">5</span> -->
                    </a>
                </li>
                <li class="nav-item">
                    <a href="myOrder.html">
                        <i class="la la-dashboard"></i>
                        <p>我的订单</p>
                        <!-- <span class="badge badge-count">5</span> -->
                    </a>
                </li>
                <li class="nav-item">
                    <a href="guarantee.html">
                        <i class="la la-table"></i>
                        <p>我的保单</p>
                        <!-- <span class="badge badge-count">14</span> -->
                    </a>
                </li>
                <li class="nav-item">
                    <a href="claim.html">
                        <i class="la la-keyboard-o"></i>
                        <p>我的理赔</p>
                        <!-- <span class="badge badge-count">50</span> -->
                    </a>
                </li>
                <li class="nav-item">
                    <a href="notifications.html">
                        <i class="la la-th"></i>
                        <p>我的车辆</p>
                        <!-- <span class="badge badge-count">6</span> -->
                    </a>
                </li>
                <li class="nav-item">
                    <a href="applyclaim.html">
                        <i class="la la-th"></i>
                        <p>申请理赔</p>
                        <!-- <span class="badge badge-count">6</span> -->
                    </a>
                </li>
            </ul>
        </div>
    </div>
    <div class="main-panel">
        <div class="content">
            <div class="container-fluid">
                <h4 class="page-title">实名认证</h4>
                <div class="row">
                    <div class="col-md-12" ng-repeat="s in list">
                        <div class="card">
                            <div class="card-header">
                                <h4 class="card-title">居民身份证反面(肖像)上传</h4>
                            </div>
                            <div class="card-body">
                                <form action="" method="post" enctype="multipart/form-data">
                                    <input class="btn btn-default" type="file" id="img" name="img"
                                           accept="image/png,image/jpeg,image/jpg"/>

                                    <button type="button" onclick="upload()" class="btn btn-default"> 提 交</button>
                                </form>

                                <p class="card-category">图片格式支持jpg、png、bmp，图片的长和宽要求最短边大于10px，最长边小于2048 px;</p>
                                <p class="card-category">图片大小必须小于4M，建议不要超过1M；</p>
                                <p class="card-category">请尽量将图片高和宽都控制在1000 px以下，图片尽量没有反光、倾斜小于10度;</p>
                                <br>
                                <div id="cardDemo">
                                    <img id="imgPath" src="assets/img/idCardDemo.png" height="180px" width="290px"
                                         alt="身份证示例"/>
                                </div>
                                <div class="text-left">
                                    <button id="save" onclick="save()" class="btn btn-default"> 实名认证</button>
                                </div>

                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<body>

</body>
</html>